package com.neuedu.yyzx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.config.CommonResult;
import com.neuedu.yyzx.entity.HandleEmerg;
import com.neuedu.yyzx.entity.LifeRemind;
import com.neuedu.yyzx.service.IHandleEmergService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 第7组....
 * @since 2021-04-28
 */
@RestController
@RequestMapping("//handleEmerg")
public class HandleEmergController {


    @Autowired
    IHandleEmergService handleEmergService;

    @RequestMapping("/list")
    public CommonResult list(@RequestParam(defaultValue = "1") Integer pageNo , @RequestParam(defaultValue = "10") Integer pageSize, HandleEmerg handleEmerg){
        QueryWrapper queryWrapper = new QueryWrapper();
        if(handleEmerg!=null && StringUtils.isNotEmpty(handleEmerg.getName())){
            queryWrapper.like("name",handleEmerg.getName());
        }

        return CommonResult.success(handleEmergService.page(new Page<>(pageNo,pageSize),queryWrapper));

    }

    @RequestMapping("/add")
    CommonResult add(HandleEmerg handleEmerg){
        return CommonResult.success(handleEmergService.saveOrUpdate(handleEmerg));
    }




    @RequestMapping("/update")
    CommonResult update(HandleEmerg handleEmerg){
        return CommonResult.success(handleEmergService.updateById(handleEmerg));
    }

    
    @RequestMapping("/getById")
    CommonResult getById(Integer id){
        return CommonResult.success(handleEmergService.getById(id));
    }

    @RequestMapping("/del")
    CommonResult del(Integer id){
        return CommonResult.success(handleEmergService.removeById(id));
    }

}
